package online.heycm.codegenerator.generator;

import org.springframework.util.StringUtils;

import java.util.StringJoiner;

/**
 * @author hey
 * @version 1.0
 * @date 2023/12/21 9:45
 */
public class GeneratorHelper {

    private GeneratorHelper() {}

    public static String packageToPath(String packageStr) {
        if (!StringUtils.hasText(packageStr)) {
            return "/";
        }
        String[] packages = packageStr.split("\\.");
        if (packages.length <= 1) {
            return "/" + packages[0];
        }
        return "/" + String.join("/", packages);
    }

    public static void main(String[] args) {

        System.out.println(packageToPath("com"));
        System.out.println(packageToPath("com.tt"));
        System.out.println(packageToPath("com.tt.bb"));

    }
}
